/*! For license information please see 947.js.LICENSE.txt */
(self.webpackChunkmp_webgl = self.webpackChunkmp_webgl || []).push([
  [947],
  {
    80645: (t, e) => {
      (e.read = function (t, e, n, r, i) {
        var s,
          o,
          a = 8 * i - r - 1,
          c = (1 << a) - 1,
          u = c >> 1,
          l = -7,
          f = n ? i - 1 : 0,
          h = n ? -1 : 1,
          d = t[e + f];
        for (
          f += h, s = d & ((1 << -l) - 1), d >>= -l, l += a;
          l > 0;
          s = 256 * s + t[e + f], f += h, l -= 8
        );
        for (
          o = s & ((1 << -l) - 1), s >>= -l, l += r;
          l > 0;
          o = 256 * o + t[e + f], f += h, l -= 8
        );
        if (0 === s) s = 1 - u;
        else {
          if (s === c) return o ? NaN : (1 / 0) * (d ? -1 : 1);
          (o += Math.pow(2, r)), (s -= u);
        }
        return (d ? -1 : 1) * o * Math.pow(2, s - r);
      }),
        (e.write = function (t, e, n, r, i, s) {
          var o,
            a,
            c,
            u = 8 * s - i - 1,
            l = (1 << u) - 1,
            f = l >> 1,
            h = 23 === i ? Math.pow(2, -24) - Math.pow(2, -77) : 0,
            d = r ? 0 : s - 1,
            p = r ? 1 : -1,
            w = e < 0 || (0 === e && 1 / e < 0) ? 1 : 0;
          for (
            e = Math.abs(e),
              isNaN(e) || e === 1 / 0
                ? ((a = isNaN(e) ? 1 : 0), (o = l))
                : ((o = Math.floor(Math.log(e) / Math.LN2)),
                  e * (c = Math.pow(2, -o)) < 1 && (o--, (c *= 2)),
                  (e += o + f >= 1 ? h / c : h * Math.pow(2, 1 - f)) * c >= 2 &&
                    (o++, (c /= 2)),
                  o + f >= l
                    ? ((a = 0), (o = l))
                    : o + f >= 1
                    ? ((a = (e * c - 1) * Math.pow(2, i)), (o += f))
                    : ((a = e * Math.pow(2, f - 1) * Math.pow(2, i)), (o = 0)));
            i >= 8;
            t[n + d] = 255 & a, d += p, a /= 256, i -= 8
          );
          for (
            o = (o << i) | a, u += i;
            u > 0;
            t[n + d] = 255 & o, d += p, o /= 256, u -= 8
          );
          t[n + d - p] |= 128 * w;
        });
    },
    3614: (t, e, n) => {
      "use strict";
      t.exports = i;
      var r = n(80645);
      function i(t) {
        (this.buf =
          ArrayBuffer.isView && ArrayBuffer.isView(t)
            ? t
            : new Uint8Array(t || 0)),
          (this.pos = 0),
          (this.type = 0),
          (this.length = this.buf.length);
      }
      (i.Varint = 0), (i.Fixed64 = 1), (i.Bytes = 2), (i.Fixed32 = 5);
      var s = 4294967296,
        o = 1 / s;
      function a(t) {
        return t.type === i.Bytes ? t.readVarint() + t.pos : t.pos + 1;
      }
      function c(t, e, n) {
        return n
          ? 4294967296 * e + (t >>> 0)
          : 4294967296 * (e >>> 0) + (t >>> 0);
      }
      function u(t, e, n) {
        var r =
          e <= 16383
            ? 1
            : e <= 2097151
            ? 2
            : e <= 268435455
            ? 3
            : Math.ceil(Math.log(e) / (7 * Math.LN2));
        n.realloc(r);
        for (var i = n.pos - 1; i >= t; i--) n.buf[i + r] = n.buf[i];
      }
      function l(t, e) {
        for (var n = 0; n < t.length; n++) e.writeVarint(t[n]);
      }
      function f(t, e) {
        for (var n = 0; n < t.length; n++) e.writeSVarint(t[n]);
      }
      function h(t, e) {
        for (var n = 0; n < t.length; n++) e.writeFloat(t[n]);
      }
      function d(t, e) {
        for (var n = 0; n < t.length; n++) e.writeDouble(t[n]);
      }
      function p(t, e) {
        for (var n = 0; n < t.length; n++) e.writeBoolean(t[n]);
      }
      function w(t, e) {
        for (var n = 0; n < t.length; n++) e.writeFixed32(t[n]);
      }
      function g(t, e) {
        for (var n = 0; n < t.length; n++) e.writeSFixed32(t[n]);
      }
      function y(t, e) {
        for (var n = 0; n < t.length; n++) e.writeFixed64(t[n]);
      }
      function x(t, e) {
        for (var n = 0; n < t.length; n++) e.writeSFixed64(t[n]);
      }
      function m(t, e) {
        return (
          (t[e] | (t[e + 1] << 8) | (t[e + 2] << 16)) + 16777216 * t[e + 3]
        );
      }
      function B(t, e, n) {
        (t[n] = e),
          (t[n + 1] = e >>> 8),
          (t[n + 2] = e >>> 16),
          (t[n + 3] = e >>> 24);
      }
      function b(t, e) {
        return (t[e] | (t[e + 1] << 8) | (t[e + 2] << 16)) + (t[e + 3] << 24);
      }
      i.prototype = {
        destroy: function () {
          this.buf = null;
        },
        readFields: function (t, e, n) {
          for (n = n || this.length; this.pos < n; ) {
            var r = this.readVarint(),
              i = r >> 3,
              s = this.pos;
            (this.type = 7 & r), t(i, e, this), this.pos === s && this.skip(r);
          }
          return e;
        },
        readMessage: function (t, e) {
          return this.readFields(t, e, this.readVarint() + this.pos);
        },
        readFixed32: function () {
          var t = m(this.buf, this.pos);
          return (this.pos += 4), t;
        },
        readSFixed32: function () {
          var t = b(this.buf, this.pos);
          return (this.pos += 4), t;
        },
        readFixed64: function () {
          var t = m(this.buf, this.pos) + m(this.buf, this.pos + 4) * s;
          return (this.pos += 8), t;
        },
        readSFixed64: function () {
          var t = m(this.buf, this.pos) + b(this.buf, this.pos + 4) * s;
          return (this.pos += 8), t;
        },
        readFloat: function () {
          var t = r.read(this.buf, this.pos, !0, 23, 4);
          return (this.pos += 4), t;
        },
        readDouble: function () {
          var t = r.read(this.buf, this.pos, !0, 52, 8);
          return (this.pos += 8), t;
        },
        readVarint: function (t) {
          var e,
            n,
            r = this.buf;
          return (
            (e = 127 & (n = r[this.pos++])),
            n < 128
              ? e
              : ((e |= (127 & (n = r[this.pos++])) << 7),
                n < 128
                  ? e
                  : ((e |= (127 & (n = r[this.pos++])) << 14),
                    n < 128
                      ? e
                      : ((e |= (127 & (n = r[this.pos++])) << 21),
                        n < 128
                          ? e
                          : (function (t, e, n) {
                              var r,
                                i,
                                s = n.buf;
                              if (
                                ((i = s[n.pos++]),
                                (r = (112 & i) >> 4),
                                i < 128)
                              )
                                return c(t, r, e);
                              if (
                                ((i = s[n.pos++]),
                                (r |= (127 & i) << 3),
                                i < 128)
                              )
                                return c(t, r, e);
                              if (
                                ((i = s[n.pos++]),
                                (r |= (127 & i) << 10),
                                i < 128)
                              )
                                return c(t, r, e);
                              if (
                                ((i = s[n.pos++]),
                                (r |= (127 & i) << 17),
                                i < 128)
                              )
                                return c(t, r, e);
                              if (
                                ((i = s[n.pos++]),
                                (r |= (127 & i) << 24),
                                i < 128)
                              )
                                return c(t, r, e);
                              if (
                                ((i = s[n.pos++]),
                                (r |= (1 & i) << 31),
                                i < 128)
                              )
                                return c(t, r, e);
                              throw new Error(
                                "Expected varint not more than 10 bytes"
                              );
                            })(
                              (e |= (15 & (n = r[this.pos])) << 28),
                              t,
                              this
                            ))))
          );
        },
        readVarint64: function () {
          return this.readVarint(!0);
        },
        readSVarint: function () {
          var t = this.readVarint();
          return t % 2 == 1 ? (t + 1) / -2 : t / 2;
        },
        readBoolean: function () {
          return Boolean(this.readVarint());
        },
        readString: function () {
          var t = this.readVarint() + this.pos,
            e = (function (t, e, n) {
              var r = "",
                i = e;
              for (; i < n; ) {
                var s,
                  o,
                  a,
                  c = t[i],
                  u = null,
                  l = c > 239 ? 4 : c > 223 ? 3 : c > 191 ? 2 : 1;
                if (i + l > n) break;
                1 === l
                  ? c < 128 && (u = c)
                  : 2 === l
                  ? 128 == (192 & (s = t[i + 1])) &&
                    (u = ((31 & c) << 6) | (63 & s)) <= 127 &&
                    (u = null)
                  : 3 === l
                  ? ((s = t[i + 1]),
                    (o = t[i + 2]),
                    128 == (192 & s) &&
                      128 == (192 & o) &&
                      ((u = ((15 & c) << 12) | ((63 & s) << 6) | (63 & o)) <=
                        2047 ||
                        (u >= 55296 && u <= 57343)) &&
                      (u = null))
                  : 4 === l &&
                    ((s = t[i + 1]),
                    (o = t[i + 2]),
                    (a = t[i + 3]),
                    128 == (192 & s) &&
                      128 == (192 & o) &&
                      128 == (192 & a) &&
                      ((u =
                        ((15 & c) << 18) |
                        ((63 & s) << 12) |
                        ((63 & o) << 6) |
                        (63 & a)) <= 65535 ||
                        u >= 1114112) &&
                      (u = null)),
                  null === u
                    ? ((u = 65533), (l = 1))
                    : u > 65535 &&
                      ((u -= 65536),
                      (r += String.fromCharCode(((u >>> 10) & 1023) | 55296)),
                      (u = 56320 | (1023 & u))),
                  (r += String.fromCharCode(u)),
                  (i += l);
              }
              return r;
            })(this.buf, this.pos, t);
          return (this.pos = t), e;
        },
        readBytes: function () {
          var t = this.readVarint() + this.pos,
            e = this.buf.subarray(this.pos, t);
          return (this.pos = t), e;
        },
        readPackedVarint: function (t, e) {
          var n = a(this);
          for (t = t || []; this.pos < n; ) t.push(this.readVarint(e));
          return t;
        },
        readPackedSVarint: function (t) {
          var e = a(this);
          for (t = t || []; this.pos < e; ) t.push(this.readSVarint());
          return t;
        },
        readPackedBoolean: function (t) {
          var e = a(this);
          for (t = t || []; this.pos < e; ) t.push(this.readBoolean());
          return t;
        },
        readPackedFloat: function (t) {
          var e = a(this);
          for (t = t || []; this.pos < e; ) t.push(this.readFloat());
          return t;
        },
        readPackedDouble: function (t) {
          var e = a(this);
          for (t = t || []; this.pos < e; ) t.push(this.readDouble());
          return t;
        },
        readPackedFixed32: function (t) {
          var e = a(this);
          for (t = t || []; this.pos < e; ) t.push(this.readFixed32());
          return t;
        },
        readPackedSFixed32: function (t) {
          var e = a(this);
          for (t = t || []; this.pos < e; ) t.push(this.readSFixed32());
          return t;
        },
        readPackedFixed64: function (t) {
          var e = a(this);
          for (t = t || []; this.pos < e; ) t.push(this.readFixed64());
          return t;
        },
        readPackedSFixed64: function (t) {
          var e = a(this);
          for (t = t || []; this.pos < e; ) t.push(this.readSFixed64());
          return t;
        },
        skip: function (t) {
          var e = 7 & t;
          if (e === i.Varint) for (; this.buf[this.pos++] > 127; );
          else if (e === i.Bytes) this.pos = this.readVarint() + this.pos;
          else if (e === i.Fixed32) this.pos += 4;
          else {
            if (e !== i.Fixed64) throw new Error("Unimplemented type: " + e);
            this.pos += 8;
          }
        },
        writeTag: function (t, e) {
          this.writeVarint((t << 3) | e);
        },
        realloc: function (t) {
          for (var e = this.length || 16; e < this.pos + t; ) e *= 2;
          if (e !== this.length) {
            var n = new Uint8Array(e);
            n.set(this.buf), (this.buf = n), (this.length = e);
          }
        },
        finish: function () {
          return (
            (this.length = this.pos),
            (this.pos = 0),
            this.buf.subarray(0, this.length)
          );
        },
        writeFixed32: function (t) {
          this.realloc(4), B(this.buf, t, this.pos), (this.pos += 4);
        },
        writeSFixed32: function (t) {
          this.realloc(4), B(this.buf, t, this.pos), (this.pos += 4);
        },
        writeFixed64: function (t) {
          this.realloc(8),
            B(this.buf, -1 & t, this.pos),
            B(this.buf, Math.floor(t * o), this.pos + 4),
            (this.pos += 8);
        },
        writeSFixed64: function (t) {
          this.realloc(8),
            B(this.buf, -1 & t, this.pos),
            B(this.buf, Math.floor(t * o), this.pos + 4),
            (this.pos += 8);
        },
        writeVarint: function (t) {
          (t = +t || 0) > 268435455 || t < 0
            ? (function (t, e) {
                var n, r;
                t >= 0
                  ? ((n = t % 4294967296 | 0), (r = (t / 4294967296) | 0))
                  : ((r = ~(-t / 4294967296)),
                    4294967295 ^ (n = ~(-t % 4294967296))
                      ? (n = (n + 1) | 0)
                      : ((n = 0), (r = (r + 1) | 0)));
                if (t >= 0x10000000000000000 || t < -0x10000000000000000)
                  throw new Error("Given varint doesn't fit into 10 bytes");
                e.realloc(10),
                  (function (t, e, n) {
                    (n.buf[n.pos++] = (127 & t) | 128),
                      (t >>>= 7),
                      (n.buf[n.pos++] = (127 & t) | 128),
                      (t >>>= 7),
                      (n.buf[n.pos++] = (127 & t) | 128),
                      (t >>>= 7),
                      (n.buf[n.pos++] = (127 & t) | 128),
                      (t >>>= 7),
                      (n.buf[n.pos] = 127 & t);
                  })(n, 0, e),
                  (function (t, e) {
                    var n = (7 & t) << 4;
                    if (((e.buf[e.pos++] |= n | ((t >>>= 3) ? 128 : 0)), !t))
                      return;
                    if (
                      ((e.buf[e.pos++] = (127 & t) | ((t >>>= 7) ? 128 : 0)),
                      !t)
                    )
                      return;
                    if (
                      ((e.buf[e.pos++] = (127 & t) | ((t >>>= 7) ? 128 : 0)),
                      !t)
                    )
                      return;
                    if (
                      ((e.buf[e.pos++] = (127 & t) | ((t >>>= 7) ? 128 : 0)),
                      !t)
                    )
                      return;
                    if (
                      ((e.buf[e.pos++] = (127 & t) | ((t >>>= 7) ? 128 : 0)),
                      !t)
                    )
                      return;
                    e.buf[e.pos++] = 127 & t;
                  })(r, e);
              })(t, this)
            : (this.realloc(4),
              (this.buf[this.pos++] = (127 & t) | (t > 127 ? 128 : 0)),
              t <= 127 ||
                ((this.buf[this.pos++] =
                  (127 & (t >>>= 7)) | (t > 127 ? 128 : 0)),
                t <= 127 ||
                  ((this.buf[this.pos++] =
                    (127 & (t >>>= 7)) | (t > 127 ? 128 : 0)),
                  t <= 127 || (this.buf[this.pos++] = (t >>> 7) & 127))));
        },
        writeSVarint: function (t) {
          this.writeVarint(t < 0 ? 2 * -t - 1 : 2 * t);
        },
        writeBoolean: function (t) {
          this.writeVarint(Boolean(t));
        },
        writeString: function (t) {
          (t = String(t)), this.realloc(4 * t.length), this.pos++;
          var e = this.pos;
          this.pos = (function (t, e, n) {
            for (var r, i, s = 0; s < e.length; s++) {
              if ((r = e.charCodeAt(s)) > 55295 && r < 57344) {
                if (!i) {
                  r > 56319 || s + 1 === e.length
                    ? ((t[n++] = 239), (t[n++] = 191), (t[n++] = 189))
                    : (i = r);
                  continue;
                }
                if (r < 56320) {
                  (t[n++] = 239), (t[n++] = 191), (t[n++] = 189), (i = r);
                  continue;
                }
                (r = ((i - 55296) << 10) | (r - 56320) | 65536), (i = null);
              } else
                i &&
                  ((t[n++] = 239), (t[n++] = 191), (t[n++] = 189), (i = null));
              r < 128
                ? (t[n++] = r)
                : (r < 2048
                    ? (t[n++] = (r >> 6) | 192)
                    : (r < 65536
                        ? (t[n++] = (r >> 12) | 224)
                        : ((t[n++] = (r >> 18) | 240),
                          (t[n++] = ((r >> 12) & 63) | 128)),
                      (t[n++] = ((r >> 6) & 63) | 128)),
                  (t[n++] = (63 & r) | 128));
            }
            return n;
          })(this.buf, t, this.pos);
          var n = this.pos - e;
          n >= 128 && u(e, n, this),
            (this.pos = e - 1),
            this.writeVarint(n),
            (this.pos += n);
        },
        writeFloat: function (t) {
          this.realloc(4),
            r.write(this.buf, t, this.pos, !0, 23, 4),
            (this.pos += 4);
        },
        writeDouble: function (t) {
          this.realloc(8),
            r.write(this.buf, t, this.pos, !0, 52, 8),
            (this.pos += 8);
        },
        writeBytes: function (t) {
          var e = t.length;
          this.writeVarint(e), this.realloc(e);
          for (var n = 0; n < e; n++) this.buf[this.pos++] = t[n];
        },
        writeRawMessage: function (t, e) {
          this.pos++;
          var n = this.pos;
          t(e, this);
          var r = this.pos - n;
          r >= 128 && u(n, r, this),
            (this.pos = n - 1),
            this.writeVarint(r),
            (this.pos += r);
        },
        writeMessage: function (t, e, n) {
          this.writeTag(t, i.Bytes), this.writeRawMessage(e, n);
        },
        writePackedVarint: function (t, e) {
          this.writeMessage(t, l, e);
        },
        writePackedSVarint: function (t, e) {
          this.writeMessage(t, f, e);
        },
        writePackedBoolean: function (t, e) {
          this.writeMessage(t, p, e);
        },
        writePackedFloat: function (t, e) {
          this.writeMessage(t, h, e);
        },
        writePackedDouble: function (t, e) {
          this.writeMessage(t, d, e);
        },
        writePackedFixed32: function (t, e) {
          this.writeMessage(t, w, e);
        },
        writePackedSFixed32: function (t, e) {
          this.writeMessage(t, g, e);
        },
        writePackedFixed64: function (t, e) {
          this.writeMessage(t, y, e);
        },
        writePackedSFixed64: function (t, e) {
          this.writeMessage(t, x, e);
        },
        writeBytesField: function (t, e) {
          this.writeTag(t, i.Bytes), this.writeBytes(e);
        },
        writeFixed32Field: function (t, e) {
          this.writeTag(t, i.Fixed32), this.writeFixed32(e);
        },
        writeSFixed32Field: function (t, e) {
          this.writeTag(t, i.Fixed32), this.writeSFixed32(e);
        },
        writeFixed64Field: function (t, e) {
          this.writeTag(t, i.Fixed64), this.writeFixed64(e);
        },
        writeSFixed64Field: function (t, e) {
          this.writeTag(t, i.Fixed64), this.writeSFixed64(e);
        },
        writeVarintField: function (t, e) {
          this.writeTag(t, i.Varint), this.writeVarint(e);
        },
        writeSVarintField: function (t, e) {
          this.writeTag(t, i.Varint), this.writeSVarint(e);
        },
        writeStringField: function (t, e) {
          this.writeTag(t, i.Bytes), this.writeString(e);
        },
        writeFloatField: function (t, e) {
          this.writeTag(t, i.Fixed32), this.writeFloat(e);
        },
        writeDoubleField: function (t, e) {
          this.writeTag(t, i.Fixed64), this.writeDouble(e);
        },
        writeBooleanField: function (t, e) {
          this.writeVarintField(t, Boolean(e));
        },
      };
    },
    96367: (t, e, n) => {
      "use strict";
      n.d(e, { r: () => MeshBVH });
      var r = n(2212);
      class MeshBVHNode {
        constructor() {}
      }
      function i(t, e, n) {
        return (
          (n.min.x = e[t]),
          (n.min.y = e[t + 1]),
          (n.min.z = e[t + 2]),
          (n.max.x = e[t + 3]),
          (n.max.y = e[t + 4]),
          (n.max.z = e[t + 5]),
          n
        );
      }
      function s(t) {
        let e = -1,
          n = -1 / 0;
        for (let r = 0; r < 3; r++) {
          const i = t[r + 3] - t[r];
          i > n && ((n = i), (e = r));
        }
        return e;
      }
      function o(t, e) {
        e.set(t);
      }
      function a(t, e, n) {
        let r, i;
        for (let s = 0; s < 3; s++) {
          const o = s + 3;
          (r = t[s]),
            (i = e[s]),
            (n[s] = r < i ? r : i),
            (r = t[o]),
            (i = e[o]),
            (n[o] = r > i ? r : i);
        }
      }
      function c(t) {
        const e = t[3] - t[0],
          n = t[4] - t[1],
          r = t[5] - t[2];
        return 2 * (e * n + n * r + r * e);
      }
      const u = Math.pow(2, -24);
      function l(t, e, n, r, i = null) {
        let s = 1 / 0,
          o = 1 / 0,
          a = 1 / 0,
          c = -1 / 0,
          u = -1 / 0,
          l = -1 / 0,
          f = 1 / 0,
          h = 1 / 0,
          d = 1 / 0,
          p = -1 / 0,
          w = -1 / 0,
          g = -1 / 0;
        const y = null !== i;
        for (let r = 6 * e, i = 6 * (e + n); r < i; r += 6) {
          const e = t[r + 0],
            n = t[r + 1],
            i = e - n,
            x = e + n;
          i < s && (s = i),
            x > c && (c = x),
            y && e < f && (f = e),
            y && e > p && (p = e);
          const m = t[r + 2],
            B = t[r + 3],
            b = m - B,
            V = m + B;
          b < o && (o = b),
            V > u && (u = V),
            y && m < h && (h = m),
            y && m > w && (w = m);
          const T = t[r + 4],
            M = t[r + 5],
            P = T - M,
            S = T + M;
          P < a && (a = P),
            S > l && (l = S),
            y && T < d && (d = T),
            y && T > g && (g = T);
        }
        (r[0] = s),
          (r[1] = o),
          (r[2] = a),
          (r[3] = c),
          (r[4] = u),
          (r[5] = l),
          y &&
            ((i[0] = f),
            (i[1] = h),
            (i[2] = d),
            (i[3] = p),
            (i[4] = w),
            (i[5] = g));
      }
      const f = 32,
        h = new Array(f)
          .fill()
          .map(() => ({
            count: 0,
            bounds: new Float32Array(6),
            rightCacheBounds: new Float32Array(6),
            candidate: 0,
          })),
        d = new Float32Array(6);
      function p(t, e) {
        function n(e, r, i, u = null, V = 0) {
          if (
            (!b &&
              V >= y &&
              ((b = !0),
              x &&
                (console.warn(
                  `MeshBVH: Max depth of ${y} reached when generating BVH. Consider increasing maxDepth.`
                ),
                console.warn(t))),
            i <= m || V >= y)
          )
            return (e.offset = r), (e.count = i), e;
          const T = (function (t, e, n, r, i, u) {
            let l = -1,
              p = 0;
            if (0 === u) (l = s(e)), -1 !== l && (p = (e[l] + e[l + 3]) / 2);
            else if (1 === u)
              (l = s(t)),
                -1 !== l &&
                  (p = (function (t, e, n, r) {
                    let i = 0;
                    for (let s = e, o = e + n; s < o; s++)
                      i += t[6 * s + 2 * r];
                    return i / n;
                  })(n, r, i, l));
            else if (2 === u) {
              const s = c(t);
              let u = 1.25 * i;
              const w = 6 * r,
                g = 6 * (r + i);
              for (let t = 0; t < 3; t++) {
                const r = e[t],
                  y = (e[t + 3] - r) / f;
                for (let t = 0; t < f; t++) {
                  const e = h[t];
                  (e.count = 0), (e.candidate = r + y + t * y);
                  const n = e.bounds;
                  for (let t = 0; t < 3; t++)
                    (n[t] = 1 / 0), (n[t + 3] = -1 / 0);
                }
                for (let e = w; e < g; e += 6) {
                  let i = ~~((n[e + 2 * t] - r) / y);
                  i >= f && (i = 31);
                  const s = h[i];
                  s.count++;
                  const o = s.bounds;
                  for (let t = 0; t < 3; t++) {
                    const r = n[e + 2 * t],
                      i = n[e + 2 * t + 1],
                      s = r - i,
                      a = r + i;
                    s < o[t] && (o[t] = s), a > o[t + 3] && (o[t + 3] = a);
                  }
                }
                const x = h[31];
                o(x.bounds, x.rightCacheBounds);
                for (let t = 30; t >= 0; t--) {
                  const e = h[t],
                    n = h[t + 1];
                  a(e.bounds, n.rightCacheBounds, e.rightCacheBounds);
                }
                let m = 0;
                for (let e = 0; e < 31; e++) {
                  const n = h[e],
                    r = n.count,
                    f = n.bounds,
                    w = h[e + 1].rightCacheBounds;
                  0 !== r && (0 === m ? o(f, d) : a(f, d, d)), (m += r);
                  let g = 0,
                    y = 0;
                  0 !== m && (g = c(d) / s);
                  const x = i - m;
                  0 !== x && (y = c(w) / s);
                  const B = 1 + 1.25 * (g * m + y * x);
                  B < u && ((l = t), (u = B), (p = n.candidate));
                }
              }
            }
            return { axis: l, pos: p };
          })(e.boundingData, u, w, r, i, B);
          if (-1 === T.axis) return (e.offset = r), (e.count = i), e;
          const M = (function (t, e, n, r, i) {
            let s = n,
              o = n + r - 1;
            const a = i.pos,
              c = 2 * i.axis;
            for (;;) {
              for (; s <= o && e[6 * s + c] < a; ) s++;
              for (; s <= o && e[6 * o + c] >= a; ) o--;
              if (!(s < o)) return s;
              for (let n = 0; n < 3; n++) {
                let r = t[3 * s + n];
                (t[3 * s + n] = t[3 * o + n]), (t[3 * o + n] = r);
                let i = e[6 * s + 2 * n + 0];
                (e[6 * s + 2 * n + 0] = e[6 * o + 2 * n + 0]),
                  (e[6 * o + 2 * n + 0] = i);
                let a = e[6 * s + 2 * n + 1];
                (e[6 * s + 2 * n + 1] = e[6 * o + 2 * n + 1]),
                  (e[6 * o + 2 * n + 1] = a);
              }
              s++, o--;
            }
          })(g, w, r, i, T);
          if (M === r || M === r + i) (e.offset = r), (e.count = i);
          else {
            e.splitAxis = T.axis;
            const t = new MeshBVHNode(),
              s = r,
              o = M - r;
            (e.left = t),
              (t.boundingData = new Float32Array(6)),
              l(w, s, o, t.boundingData, p),
              n(t, s, o, p, V + 1);
            const a = new MeshBVHNode(),
              c = M,
              u = i - o;
            (e.right = a),
              (a.boundingData = new Float32Array(6)),
              l(w, c, u, a.boundingData, p),
              n(a, c, u, p, V + 1);
          }
          return e;
        }
        !(function (t, e) {
          if (!t.index) {
            const n = t.attributes.position.count,
              i = e.useSharedArrayBuffer ? SharedArrayBuffer : ArrayBuffer;
            let s;
            (s =
              n > 65535
                ? new Uint32Array(new i(4 * n))
                : new Uint16Array(new i(2 * n))),
              t.setIndex(new r.BufferAttribute(s, 1));
            for (let t = 0; t < n; t++) s[t] = t;
          }
        })(t, e);
        const i = new Float32Array(6),
          p = new Float32Array(6),
          w = (function (t, e) {
            const n = t.attributes.position,
              r = n.array,
              i = t.index.array,
              s = i.length / 3,
              o = new Float32Array(6 * s),
              a = n.offset || 0;
            let c = 3;
            n.isInterleavedBufferAttribute && (c = n.data.stride);
            for (let t = 0; t < s; t++) {
              const n = 3 * t,
                s = 6 * t,
                l = i[n + 0] * c + a,
                f = i[n + 1] * c + a,
                h = i[n + 2] * c + a;
              for (let t = 0; t < 3; t++) {
                const n = r[l + t],
                  i = r[f + t],
                  a = r[h + t];
                let c = n;
                i < c && (c = i), a < c && (c = a);
                let d = n;
                i > d && (d = i), a > d && (d = a);
                const p = (d - c) / 2,
                  w = 2 * t;
                (o[s + w + 0] = c + p),
                  (o[s + w + 1] = p + (Math.abs(c) + p) * u),
                  c < e[t] && (e[t] = c),
                  d > e[t + 3] && (e[t + 3] = d);
              }
            }
            return o;
          })(t, i),
          g = t.index.array,
          y = e.maxDepth,
          x = e.verbose,
          m = e.maxLeafTris,
          B = e.strategy;
        let b = !1;
        const V = [],
          T = (function (t) {
            if (!t.groups || !t.groups.length)
              return [{ offset: 0, count: t.index.count / 3 }];
            const e = [],
              n = new Set();
            for (const e of t.groups) n.add(e.start), n.add(e.start + e.count);
            const r = Array.from(n.values()).sort((t, e) => t - e);
            for (let t = 0; t < r.length - 1; t++) {
              const n = r[t],
                i = r[t + 1];
              e.push({ offset: n / 3, count: (i - n) / 3 });
            }
            return e;
          })(t);
        if (1 === T.length) {
          const t = T[0],
            e = new MeshBVHNode();
          (e.boundingData = i),
            (function (t, e, n, r) {
              let i = 1 / 0,
                s = 1 / 0,
                o = 1 / 0,
                a = -1 / 0,
                c = -1 / 0,
                u = -1 / 0;
              for (let r = 6 * e, l = 6 * (e + n); r < l; r += 6) {
                const e = t[r + 0];
                e < i && (i = e), e > a && (a = e);
                const n = t[r + 2];
                n < s && (s = n), n > c && (c = n);
                const l = t[r + 4];
                l < o && (o = l), l > u && (u = l);
              }
              (r[0] = i),
                (r[1] = s),
                (r[2] = o),
                (r[3] = a),
                (r[4] = c),
                (r[5] = u);
            })(w, t.offset, t.count, p),
            n(e, t.offset, t.count, p),
            V.push(e);
        } else
          for (let t of T) {
            const e = new MeshBVHNode();
            (e.boundingData = new Float32Array(6)),
              l(w, t.offset, t.count, e.boundingData, p),
              n(e, t.offset, t.count, p),
              V.push(e);
          }
        return V;
      }
      const w = 65535;
      class SeparatingAxisBounds {
        constructor() {
          (this.min = 1 / 0), (this.max = -1 / 0);
        }
        setFromPointsField(t, e) {
          let n = 1 / 0,
            r = -1 / 0;
          for (let i = 0, s = t.length; i < s; i++) {
            const s = t[i][e];
            (n = s < n ? s : n), (r = s > r ? s : r);
          }
          (this.min = n), (this.max = r);
        }
        setFromPoints(t, e) {
          let n = 1 / 0,
            r = -1 / 0;
          for (let i = 0, s = e.length; i < s; i++) {
            const s = e[i],
              o = t.dot(s);
            (n = o < n ? o : n), (r = o > r ? o : r);
          }
          (this.min = n), (this.max = r);
        }
        isSeparated(t) {
          return this.min > t.max || t.min > this.max;
        }
      }
      SeparatingAxisBounds.prototype.setFromBox = (function () {
        const t = new r.Vector3();
        return function (e, n) {
          const r = n.min,
            i = n.max;
          let s = 1 / 0,
            o = -1 / 0;
          for (let n = 0; n <= 1; n++)
            for (let a = 0; a <= 1; a++)
              for (let c = 0; c <= 1; c++) {
                (t.x = r.x * n + i.x * (1 - n)),
                  (t.y = r.y * a + i.y * (1 - a)),
                  (t.z = r.z * c + i.z * (1 - c));
                const u = e.dot(t);
                (s = Math.min(u, s)), (o = Math.max(u, o));
              }
          (this.min = s), (this.max = o);
        };
      })();
      !(function () {
        const t = new SeparatingAxisBounds();
      })();
      const g = (function () {
          const t = new r.Vector3(),
            e = new r.Vector3(),
            n = new r.Vector3();
          return function (r, i, s) {
            const o = r.start,
              a = t,
              c = i.start,
              u = e;
            n.subVectors(o, c),
              t.subVectors(r.end, i.start),
              e.subVectors(i.end, i.start);
            const l = n.dot(u),
              f = u.dot(a),
              h = u.dot(u),
              d = n.dot(a),
              p = a.dot(a) * h - f * f;
            let w, g;
            (w = 0 !== p ? (l * f - d * h) / p : 0),
              (g = (l + w * f) / h),
              (s.x = w),
              (s.y = g);
          };
        })(),
        y = (function () {
          const t = new r.Vector2(),
            e = new r.Vector3(),
            n = new r.Vector3();
          return function (r, i, s, o) {
            g(r, i, t);
            let a = t.x,
              c = t.y;
            if (a >= 0 && a <= 1 && c >= 0 && c <= 1)
              return r.at(a, s), void i.at(c, o);
            if (a >= 0 && a <= 1)
              return (
                c < 0 ? i.at(0, o) : i.at(1, o),
                void r.closestPointToPoint(o, !0, s)
              );
            if (c >= 0 && c <= 1)
              return (
                a < 0 ? r.at(0, s) : r.at(1, s),
                void i.closestPointToPoint(s, !0, o)
              );
            {
              let t, u;
              (t = a < 0 ? r.start : r.end), (u = c < 0 ? i.start : i.end);
              const l = e,
                f = n;
              return (
                r.closestPointToPoint(u, !0, e),
                i.closestPointToPoint(t, !0, n),
                l.distanceToSquared(u) <= f.distanceToSquared(t)
                  ? (s.copy(l), void o.copy(u))
                  : (s.copy(t), void o.copy(f))
              );
            }
          };
        })(),
        x = (function () {
          const t = new r.Vector3(),
            e = new r.Vector3(),
            n = new r.Plane(),
            i = new r.Line3();
          return function (r, s) {
            const { radius: o, center: a } = r,
              { a: c, b: u, c: l } = s;
            (i.start = c), (i.end = u);
            if (i.closestPointToPoint(a, !0, t).distanceTo(a) <= o) return !0;
            (i.start = c), (i.end = l);
            if (i.closestPointToPoint(a, !0, t).distanceTo(a) <= o) return !0;
            (i.start = u), (i.end = l);
            if (i.closestPointToPoint(a, !0, t).distanceTo(a) <= o) return !0;
            const f = s.getPlane(n);
            if (Math.abs(f.distanceToPoint(a)) <= o) {
              const t = f.projectPoint(a, e);
              if (s.containsPoint(t)) return !0;
            }
            return !1;
          };
        })();
      class SeparatingAxisTriangle extends r.Triangle {
        constructor(...t) {
          super(...t),
            (this.isSeparatingAxisTriangle = !0),
            (this.satAxes = new Array(4).fill().map(() => new r.Vector3())),
            (this.satBounds = new Array(4)
              .fill()
              .map(() => new SeparatingAxisBounds())),
            (this.points = [this.a, this.b, this.c]),
            (this.sphere = new r.Sphere()),
            (this.plane = new r.Plane()),
            (this.needsUpdate = !1);
        }
        intersectsSphere(t) {
          return x(t, this);
        }
        update() {
          const t = this.a,
            e = this.b,
            n = this.c,
            r = this.points,
            i = this.satAxes,
            s = this.satBounds,
            o = i[0],
            a = s[0];
          this.getNormal(o), a.setFromPoints(o, r);
          const c = i[1],
            u = s[1];
          c.subVectors(t, e), u.setFromPoints(c, r);
          const l = i[2],
            f = s[2];
          l.subVectors(e, n), f.setFromPoints(l, r);
          const h = i[3],
            d = s[3];
          h.subVectors(n, t),
            d.setFromPoints(h, r),
            this.sphere.setFromPoints(this.points),
            this.plane.setFromNormalAndCoplanarPoint(o, t),
            (this.needsUpdate = !1);
        }
      }
      (SeparatingAxisTriangle.prototype.closestPointToSegment = (function () {
        const t = new r.Vector3(),
          e = new r.Vector3(),
          n = new r.Line3();
        return function (r, i = null, s = null) {
          const { start: o, end: a } = r,
            c = this.points;
          let u,
            l = 1 / 0;
          for (let o = 0; o < 3; o++) {
            const a = (o + 1) % 3;
            n.start.copy(c[o]),
              n.end.copy(c[a]),
              y(n, r, t, e),
              (u = t.distanceToSquared(e)),
              u < l && ((l = u), i && i.copy(t), s && s.copy(e));
          }
          return (
            this.closestPointToPoint(o, t),
            (u = o.distanceToSquared(t)),
            u < l && ((l = u), i && i.copy(t), s && s.copy(o)),
            this.closestPointToPoint(a, t),
            (u = a.distanceToSquared(t)),
            u < l && ((l = u), i && i.copy(t), s && s.copy(a)),
            Math.sqrt(l)
          );
        };
      })()),
        (SeparatingAxisTriangle.prototype.intersectsTriangle = (function () {
          const t = new SeparatingAxisTriangle(),
            e = new Array(3),
            n = new Array(3),
            i = new SeparatingAxisBounds(),
            s = new SeparatingAxisBounds(),
            o = new r.Vector3(),
            a = new r.Vector3(),
            c = new r.Vector3(),
            u = new r.Vector3(),
            l = new r.Line3(),
            f = new r.Line3(),
            h = new r.Line3();
          return function (r, d = null) {
            this.needsUpdate && this.update(),
              r.isSeparatingAxisTriangle
                ? r.needsUpdate && r.update()
                : (t.copy(r), t.update(), (r = t));
            const p = this.satBounds,
              w = this.satAxes;
            (n[0] = r.a), (n[1] = r.b), (n[2] = r.c);
            for (let t = 0; t < 4; t++) {
              const e = p[t],
                r = w[t];
              if ((i.setFromPoints(r, n), e.isSeparated(i))) return !1;
            }
            const g = r.satBounds,
              y = r.satAxes;
            (e[0] = this.a), (e[1] = this.b), (e[2] = this.c);
            for (let t = 0; t < 4; t++) {
              const n = g[t],
                r = y[t];
              if ((i.setFromPoints(r, e), n.isSeparated(i))) return !1;
            }
            for (let t = 0; t < 4; t++) {
              const r = w[t];
              for (let t = 0; t < 4; t++) {
                const a = y[t];
                if (
                  (o.crossVectors(r, a),
                  i.setFromPoints(o, e),
                  s.setFromPoints(o, n),
                  i.isSeparated(s))
                )
                  return !1;
              }
            }
            if (d) {
              const t = this.plane,
                e = r.plane;
              if (Math.abs(t.normal.dot(e.normal)) > 1 - 1e-10)
                console.warn(
                  "SeparatingAxisTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."
                ),
                  d.start.set(0, 0, 0),
                  d.end.set(0, 0, 0);
              else {
                const n = this.points;
                let i = !1;
                for (let t = 0; t < 3; t++) {
                  const r = n[t],
                    s = n[(t + 1) % 3];
                  if (
                    (l.start.copy(r),
                    l.end.copy(s),
                    e.intersectLine(l, i ? f.start : f.end))
                  ) {
                    if (i) break;
                    i = !0;
                  }
                }
                const s = r.points;
                let o = !1;
                for (let e = 0; e < 3; e++) {
                  const n = s[e],
                    r = s[(e + 1) % 3];
                  if (
                    (l.start.copy(n),
                    l.end.copy(r),
                    t.intersectLine(l, o ? h.start : h.end))
                  ) {
                    if (o) break;
                    o = !0;
                  }
                }
                if ((f.delta(a), h.delta(c), a.dot(c) < 0)) {
                  let t = h.start;
                  (h.start = h.end), (h.end = t);
                }
                u.subVectors(f.start, h.start),
                  u.dot(a) > 0 ? d.start.copy(f.start) : d.start.copy(h.start),
                  u.subVectors(f.end, h.end),
                  u.dot(a) < 0 ? d.end.copy(f.end) : d.end.copy(h.end);
              }
            }
            return !0;
          };
        })()),
        (SeparatingAxisTriangle.prototype.distanceToPoint = (function () {
          const t = new r.Vector3();
          return function (e) {
            return this.closestPointToPoint(e, t), e.distanceTo(t);
          };
        })()),
        (SeparatingAxisTriangle.prototype.distanceToTriangle = (function () {
          const t = new r.Vector3(),
            e = new r.Vector3(),
            n = ["a", "b", "c"],
            i = new r.Line3(),
            s = new r.Line3();
          return function (r, o = null, a = null) {
            const c = o || a ? i : null;
            if (this.intersectsTriangle(r, c))
              return (o || a) && (o && c.getCenter(o), a && c.getCenter(a)), 0;
            let u = 1 / 0;
            for (let e = 0; e < 3; e++) {
              let i;
              const s = n[e],
                c = r[s];
              this.closestPointToPoint(c, t),
                (i = c.distanceToSquared(t)),
                i < u && ((u = i), o && o.copy(t), a && a.copy(c));
              const l = this[s];
              r.closestPointToPoint(l, t),
                (i = l.distanceToSquared(t)),
                i < u && ((u = i), o && o.copy(l), a && a.copy(t));
            }
            for (let c = 0; c < 3; c++) {
              const l = n[c],
                f = n[(c + 1) % 3];
              i.set(this[l], this[f]);
              for (let c = 0; c < 3; c++) {
                const l = n[c],
                  f = n[(c + 1) % 3];
                s.set(r[l], r[f]), y(i, s, t, e);
                const h = t.distanceToSquared(e);
                h < u && ((u = h), o && o.copy(t), a && a.copy(e));
              }
            }
            return Math.sqrt(u);
          };
        })());
      class OrientedBox extends r.Box3 {
        constructor(...t) {
          super(...t),
            (this.isOrientedBox = !0),
            (this.matrix = new r.Matrix4()),
            (this.invMatrix = new r.Matrix4()),
            (this.points = new Array(8).fill().map(() => new r.Vector3())),
            (this.satAxes = new Array(3).fill().map(() => new r.Vector3())),
            (this.satBounds = new Array(3)
              .fill()
              .map(() => new SeparatingAxisBounds())),
            (this.alignedSatBounds = new Array(3)
              .fill()
              .map(() => new SeparatingAxisBounds())),
            (this.needsUpdate = !1);
        }
        set(t, e, n) {
          super.set(t, e), (this.matrix = n), (this.needsUpdate = !0);
        }
        copy(t) {
          super.copy(t), this.matrix.copy(t.matrix), (this.needsUpdate = !0);
        }
      }
      (OrientedBox.prototype.update = function () {
        const t = this.matrix,
          e = this.min,
          n = this.max,
          r = this.points;
        for (let i = 0; i <= 1; i++)
          for (let s = 0; s <= 1; s++)
            for (let o = 0; o <= 1; o++) {
              const a = r[(1 * i) | (2 * s) | (4 * o)];
              (a.x = i ? n.x : e.x),
                (a.y = s ? n.y : e.y),
                (a.z = o ? n.z : e.z),
                a.applyMatrix4(t);
            }
        const i = this.satBounds,
          s = this.satAxes,
          o = r[0];
        for (let t = 0; t < 3; t++) {
          const e = s[t],
            n = i[t],
            a = r[1 << t];
          e.subVectors(o, a), n.setFromPoints(e, r);
        }
        const a = this.alignedSatBounds;
        a[0].setFromPointsField(r, "x"),
          a[1].setFromPointsField(r, "y"),
          a[2].setFromPointsField(r, "z"),
          this.invMatrix.copy(this.matrix).invert(),
          (this.needsUpdate = !1);
      }),
        (OrientedBox.prototype.intersectsBox = (function () {
          const t = new SeparatingAxisBounds();
          return function (e) {
            this.needsUpdate && this.update();
            const n = e.min,
              r = e.max,
              i = this.satBounds,
              s = this.satAxes,
              o = this.alignedSatBounds;
            if (((t.min = n.x), (t.max = r.x), o[0].isSeparated(t))) return !1;
            if (((t.min = n.y), (t.max = r.y), o[1].isSeparated(t))) return !1;
            if (((t.min = n.z), (t.max = r.z), o[2].isSeparated(t))) return !1;
            for (let n = 0; n < 3; n++) {
              const r = s[n],
                o = i[n];
              if ((t.setFromBox(r, e), o.isSeparated(t))) return !1;
            }
            return !0;
          };
        })()),
        (OrientedBox.prototype.intersectsTriangle = (function () {
          const t = new SeparatingAxisTriangle(),
            e = new Array(3),
            n = new SeparatingAxisBounds(),
            i = new SeparatingAxisBounds(),
            s = new r.Vector3();
          return function (r) {
            this.needsUpdate && this.update(),
              r.isSeparatingAxisTriangle
                ? r.needsUpdate && r.update()
                : (t.copy(r), t.update(), (r = t));
            const o = this.satBounds,
              a = this.satAxes;
            (e[0] = r.a), (e[1] = r.b), (e[2] = r.c);
            for (let t = 0; t < 3; t++) {
              const r = o[t],
                i = a[t];
              if ((n.setFromPoints(i, e), r.isSeparated(n))) return !1;
            }
            const c = r.satBounds,
              u = r.satAxes,
              l = this.points;
            for (let t = 0; t < 3; t++) {
              const e = c[t],
                r = u[t];
              if ((n.setFromPoints(r, l), e.isSeparated(n))) return !1;
            }
            for (let t = 0; t < 3; t++) {
              const r = a[t];
              for (let t = 0; t < 4; t++) {
                const o = u[t];
                if (
                  (s.crossVectors(r, o),
                  n.setFromPoints(s, e),
                  i.setFromPoints(s, l),
                  n.isSeparated(i))
                )
                  return !1;
              }
            }
            return !0;
          };
        })()),
        (OrientedBox.prototype.closestPointToPoint = function (t, e) {
          return (
            this.needsUpdate && this.update(),
            e
              .copy(t)
              .applyMatrix4(this.invMatrix)
              .clamp(this.min, this.max)
              .applyMatrix4(this.matrix),
            e
          );
        }),
        (OrientedBox.prototype.distanceToPoint = (function () {
          const t = new r.Vector3();
          return function (e) {
            return this.closestPointToPoint(e, t), e.distanceTo(t);
          };
        })()),
        (OrientedBox.prototype.distanceToBox = (function () {
          const t = ["x", "y", "z"],
            e = new Array(12).fill().map(() => new r.Line3()),
            n = new Array(12).fill().map(() => new r.Line3()),
            i = new r.Vector3(),
            s = new r.Vector3();
          return function (r, o = 0, a = null, c = null) {
            if ((this.needsUpdate && this.update(), this.intersectsBox(r)))
              return (
                (a || c) &&
                  (r.getCenter(s),
                  this.closestPointToPoint(s, i),
                  r.closestPointToPoint(i, s),
                  a && a.copy(i),
                  c && c.copy(s)),
                0
              );
            const u = o * o,
              l = r.min,
              f = r.max,
              h = this.points;
            let d = 1 / 0;
            for (let t = 0; t < 8; t++) {
              const e = h[t];
              s.copy(e).clamp(l, f);
              const n = e.distanceToSquared(s);
              if (n < d && ((d = n), a && a.copy(e), c && c.copy(s), n < u))
                return Math.sqrt(n);
            }
            let p = 0;
            for (let r = 0; r < 3; r++)
              for (let i = 0; i <= 1; i++)
                for (let s = 0; s <= 1; s++) {
                  const o = (r + 1) % 3,
                    a = (r + 2) % 3,
                    c = (1 << r) | (i << o) | (s << a),
                    u = h[(i << o) | (s << a)],
                    d = h[c];
                  e[p].set(u, d);
                  const w = t[r],
                    g = t[o],
                    y = t[a],
                    x = n[p],
                    m = x.start,
                    B = x.end;
                  (m[w] = l[w]),
                    (m[g] = i ? l[g] : f[g]),
                    (m[y] = s ? l[y] : f[g]),
                    (B[w] = f[w]),
                    (B[g] = i ? l[g] : f[g]),
                    (B[y] = s ? l[y] : f[g]),
                    p++;
                }
            for (let t = 0; t <= 1; t++)
              for (let e = 0; e <= 1; e++)
                for (let n = 0; n <= 1; n++) {
                  (s.x = t ? f.x : l.x),
                    (s.y = e ? f.y : l.y),
                    (s.z = n ? f.z : l.z),
                    this.closestPointToPoint(s, i);
                  const r = s.distanceToSquared(i);
                  if (r < d && ((d = r), a && a.copy(i), c && c.copy(s), r < u))
                    return Math.sqrt(r);
                }
            for (let t = 0; t < 12; t++) {
              const r = e[t];
              for (let t = 0; t < 12; t++) {
                const e = n[t];
                y(r, e, i, s);
                const o = i.distanceToSquared(s);
                if (o < d && ((d = o), a && a.copy(i), c && c.copy(s), o < u))
                  return Math.sqrt(o);
              }
            }
            return Math.sqrt(d);
          };
        })());
      var m = n(34003);
      function B(t, e, n, r) {
        const i = t.a,
          s = t.b,
          o = t.c;
        let a = e,
          c = e + 1,
          u = e + 2;
        n && ((a = n.getX(e)), (c = n.getX(e + 1)), (u = n.getX(e + 2))),
          (i.x = r.getX(a)),
          (i.y = r.getY(a)),
          (i.z = r.getZ(a)),
          (s.x = r.getX(c)),
          (s.y = r.getY(c)),
          (s.z = r.getZ(c)),
          (o.x = r.getX(u)),
          (o.y = r.getY(u)),
          (o.z = r.getZ(u));
      }
      function b(t, e, n, r, i, s, o) {
        const a = n.index,
          c = n.attributes.position;
        for (let n = t, u = e + t; n < u; n++)
          if ((B(o, 3 * n, a, c), (o.needsUpdate = !0), r(o, n, i, s)))
            return !0;
        return !1;
      }
      class PrimitivePool {
        constructor(t) {
          (this._getNewPrimitive = t), (this._primitives = []);
        }
        getPrimitive() {
          const t = this._primitives;
          return 0 === t.length ? this._getNewPrimitive() : t.pop();
        }
        releasePrimitive(t) {
          this._primitives.push(t);
        }
      }
      function V(t, e) {
        return 65535 === e[t + 15];
      }
      function T(t, e) {
        return e[t + 6];
      }
      function M(t, e) {
        return e[t + 14];
      }
      function P(t) {
        return t + 8;
      }
      function S(t, e) {
        return e[t + 6];
      }
      const v = new r.Box3(),
        F = new r.Vector3(),
        A = ["x", "y", "z"];
      function U(t, e, n, r, i) {
        let s = 2 * t,
          o = q,
          a = C,
          c = L;
        if (V(s, a)) {
          const o = T(t, c),
            u = M(s, a);
          (0, m.U$)(e, n, r, o, u, i);
        } else {
          const s = P(t);
          O(s, o, r, F) && U(s, e, n, r, i);
          const a = S(t, c);
          O(a, o, r, F) && U(a, e, n, r, i);
        }
      }
      function H(t, e, n, r) {
        let i = 2 * t,
          s = q,
          o = C,
          a = L;
        if (V(i, o)) {
          const s = T(t, a),
            c = M(i, o);
          return (0, m.rM)(e, n, r, s, c);
        }
        {
          const i = (function (t, e) {
              return e[t + 7];
            })(t, a),
            o = A[i],
            c = r.direction[o] >= 0;
          let u, l;
          c ? ((u = P(t)), (l = S(t, a))) : ((u = S(t, a)), (l = P(t)));
          const f = O(u, s, r, F) ? H(u, e, n, r) : null;
          if (f) {
            const t = f.point[o];
            if (c ? t <= s[l + i] : t >= s[l + i + 3]) return f;
          }
          const h = O(l, s, r, F) ? H(l, e, n, r) : null;
          return f && h ? (f.distance <= h.distance ? f : h) : f || h || null;
        }
      }
      const k = (function () {
          let t, e;
          const n = [],
            s = new PrimitivePool(() => new r.Box3());
          return function (...r) {
            (t = s.getPrimitive()), (e = s.getPrimitive()), n.push(t, e);
            const i = o(...r);
            s.releasePrimitive(t), s.releasePrimitive(e), n.pop(), n.pop();
            const a = n.length;
            return a > 0 && ((e = n[a - 1]), (t = n[a - 2])), i;
          };
          function o(n, r, s, a, c = null, u = 0, l = 0) {
            function f(t) {
              let e = 2 * t,
                n = C,
                r = L;
              for (; !V(e, n); ) e = 2 * (t = P(t));
              return T(t, r);
            }
            function h(t) {
              let e = 2 * t,
                n = C,
                r = L;
              for (; !V(e, n); ) e = 2 * (t = S(t, r));
              return T(t, r) + M(e, n);
            }
            let d = 2 * n,
              p = q,
              w = C,
              g = L;
            if (V(d, w)) {
              const e = T(n, g),
                r = M(d, w);
              return i(n, p, t), a(e, r, !1, l, u + n, t);
            }
            {
              const d = P(n),
                y = S(n, g);
              let x,
                m,
                B,
                b,
                T = d,
                M = y;
              if (
                c &&
                ((B = t),
                (b = e),
                i(T, p, B),
                i(M, p, b),
                (x = c(B)),
                (m = c(b)),
                m < x)
              ) {
                (T = y), (M = d);
                const t = x;
                (x = m), (m = t), (B = b);
              }
              B || ((B = t), i(T, p, B));
              const v = s(B, V(2 * T, w), x, l + 1, u + T);
              let F;
              if (2 === v) {
                const t = f(T);
                F = a(t, h(T) - t, !0, l + 1, u + T, B);
              } else F = v && o(T, r, s, a, c, u, l + 1);
              if (F) return !0;
              (b = e), i(M, p, b);
              const A = s(b, V(2 * M, w), m, l + 1, u + M);
              let U;
              if (2 === A) {
                const t = f(M);
                U = a(t, h(M) - t, !0, l + 1, u + M, b);
              } else U = A && o(M, r, s, a, c, u, l + 1);
              return !!U;
            }
          }
        })(),
        z = (function () {
          const t = new SeparatingAxisTriangle(),
            e = new SeparatingAxisTriangle(),
            n = new r.Matrix4(),
            s = new OrientedBox(),
            o = new OrientedBox();
          return function r(a, c, u, l, f = null) {
            let h = 2 * a,
              d = q,
              p = C,
              w = L;
            null === f &&
              (u.boundingBox || u.computeBoundingBox(),
              s.set(u.boundingBox.min, u.boundingBox.max, l),
              (f = s));
            if (!V(h, p)) {
              const t = a + 8,
                e = w[a + 6];
              i(t, d, v);
              if (f.intersectsBox(v) && r(t, c, u, l, f)) return !0;
              i(e, d, v);
              return !!(f.intersectsBox(v) && r(e, c, u, l, f));
            }
            {
              const r = c,
                s = r.index,
                f = r.attributes.position,
                g = u.index,
                y = u.attributes.position,
                x = T(a, w),
                m = M(h, p);
              if ((n.copy(l).invert(), u.boundsTree)) {
                i(a, d, o), o.matrix.copy(n), (o.needsUpdate = !0);
                return u.boundsTree.shapecast({
                  intersectsBounds: (t) => o.intersectsBox(t),
                  intersectsTriangle: (t) => {
                    t.a.applyMatrix4(l),
                      t.b.applyMatrix4(l),
                      t.c.applyMatrix4(l),
                      (t.needsUpdate = !0);
                    for (let n = 3 * x, r = 3 * (m + x); n < r; n += 3)
                      if (
                        (B(e, n, s, f),
                        (e.needsUpdate = !0),
                        t.intersectsTriangle(e))
                      )
                        return !0;
                    return !1;
                  },
                });
              }
              for (let r = 3 * x, i = m + 3 * x; r < i; r += 3) {
                B(t, r, s, f),
                  t.a.applyMatrix4(n),
                  t.b.applyMatrix4(n),
                  t.c.applyMatrix4(n),
                  (t.needsUpdate = !0);
                for (let n = 0, r = g.count; n < r; n += 3)
                  if (
                    (B(e, n, g, y),
                    (e.needsUpdate = !0),
                    t.intersectsTriangle(e))
                  )
                    return !0;
              }
            }
          };
        })();
      function O(t, e, n, r) {
        return i(t, e, v), n.intersectBox(v, r);
      }
      const I = [];
      let D, q, C, L;
      function N(t) {
        D && I.push(D),
          (D = t),
          (q = new Float32Array(t)),
          (C = new Uint16Array(t)),
          (L = new Uint32Array(t));
      }
      function _() {
        (D = null), (q = null), (C = null), (L = null), I.length && N(I.pop());
      }
      const E = Symbol("skip tree generation"),
        G = new r.Box3(),
        R = new r.Box3(),
        X = new r.Matrix4(),
        j = new OrientedBox(),
        $ = new OrientedBox(),
        Y = new r.Vector3(),
        Z = new r.Vector3(),
        W = new r.Vector3(),
        J = new r.Vector3(),
        K = new r.Vector3(),
        Q = new r.Box3(),
        tt = new PrimitivePool(() => new SeparatingAxisTriangle());
      class MeshBVH {
        static serialize(t, e = {}) {
          if (e.isBufferGeometry)
            return (
              console.warn(
                "MeshBVH.serialize: The arguments for the function have changed. See documentation for new signature."
              ),
              MeshBVH.serialize(arguments[0], {
                cloneBuffers: void 0 === arguments[2] || arguments[2],
              })
            );
          e = { cloneBuffers: !0, ...e };
          const n = t.geometry,
            r = t._roots,
            i = n.getIndex();
          let s;
          return (
            (s = e.cloneBuffers
              ? { roots: r.map((t) => t.slice()), index: i.array.slice() }
              : { roots: r, index: i.array }),
            s
          );
        }
        static deserialize(t, e, n = {}) {
          if ("boolean" == typeof n)
            return (
              console.warn(
                "MeshBVH.deserialize: The arguments for the function have changed. See documentation for new signature."
              ),
              MeshBVH.deserialize(arguments[0], arguments[1], {
                setIndex: void 0 === arguments[2] || arguments[2],
              })
            );
          n = { setIndex: !0, ...n };
          const { index: i, roots: s } = t,
            o = new MeshBVH(e, { ...n, [E]: !0 });
          if (((o._roots = s), n.setIndex)) {
            const n = e.getIndex();
            if (null === n) {
              const n = new r.BufferAttribute(t.index, 1, !1);
              e.setIndex(n);
            } else n.array !== i && (n.array.set(i), (n.needsUpdate = !0));
          }
          return o;
        }
        constructor(t, e = {}) {
          if (!t.isBufferGeometry)
            throw new Error("MeshBVH: Only BufferGeometries are supported.");
          if (t.index && t.index.isInterleavedBufferAttribute)
            throw new Error(
              "MeshBVH: InterleavedBufferAttribute is not supported for the index attribute."
            );
          if (
            (e = Object.assign(
              {
                strategy: 0,
                maxDepth: 40,
                maxLeafTris: 10,
                verbose: !0,
                useSharedArrayBuffer: !1,
                setBoundingBox: !0,
                [E]: !1,
              },
              e
            )).useSharedArrayBuffer &&
            "undefined" == typeof SharedArrayBuffer
          )
            throw new Error("MeshBVH: SharedArrayBuffer is not available.");
          (this._roots = null),
            e[E] ||
              ((this._roots = (function (t, e) {
                const n = p(t, e);
                let r, i, s;
                const o = [],
                  a = e.useSharedArrayBuffer ? SharedArrayBuffer : ArrayBuffer;
                for (let t = 0; t < n.length; t++) {
                  const e = n[t],
                    l = new a(32 * c(e));
                  (r = new Float32Array(l)),
                    (i = new Uint32Array(l)),
                    (s = new Uint16Array(l)),
                    u(0, e),
                    o.push(l);
                }
                return o;
                function c(t) {
                  return t.count ? 1 : 1 + c(t.left) + c(t.right);
                }
                function u(t, e) {
                  const n = t / 4,
                    o = t / 2,
                    a = !!e.count,
                    c = e.boundingData;
                  for (let t = 0; t < 6; t++) r[n + t] = c[t];
                  if (a) {
                    const r = e.offset,
                      a = e.count;
                    return (
                      (i[n + 6] = r), (s[o + 14] = a), (s[o + 15] = w), t + 32
                    );
                  }
                  {
                    const r = e.left,
                      s = e.right,
                      o = e.splitAxis;
                    let a;
                    if (((a = u(t + 32, r)), a / 4 > Math.pow(2, 32)))
                      throw new Error(
                        "MeshBVH: Cannot store child pointer greater than 32 bits."
                      );
                    return (i[n + 6] = a / 4), (a = u(a, s)), (i[n + 7] = o), a;
                  }
                }
              })(t, e)),
              !t.boundingBox &&
                e.setBoundingBox &&
                (t.boundingBox = this.getBoundingBox(new r.Box3()))),
            (this.geometry = t);
        }
        refit(t = null) {
          t && Array.isArray(t) && (t = new Set(t));
          const e = this.geometry,
            n = e.index.array,
            r = e.attributes.position,
            i = r.array,
            s = r.offset || 0;
          let o,
            a,
            c,
            u,
            l = 3;
          r.isInterleavedBufferAttribute && (l = r.data.stride);
          let f = 0;
          const h = this._roots;
          for (let t = 0, e = h.length; t < e; t++)
            (o = h[t]),
              (a = new Uint32Array(o)),
              (c = new Uint16Array(o)),
              (u = new Float32Array(o)),
              d(0, f),
              (f += o.byteLength);
          function d(e, r, o = !1) {
            const f = 2 * e;
            if (c[f + 15] === w) {
              const t = a[e + 6];
              let r = 1 / 0,
                o = 1 / 0,
                h = 1 / 0,
                d = -1 / 0,
                p = -1 / 0,
                w = -1 / 0;
              for (let e = 3 * t, a = 3 * (t + c[f + 14]); e < a; e++) {
                const t = n[e] * l + s,
                  a = i[t + 0],
                  c = i[t + 1],
                  u = i[t + 2];
                a < r && (r = a),
                  a > d && (d = a),
                  c < o && (o = c),
                  c > p && (p = c),
                  u < h && (h = u),
                  u > w && (w = u);
              }
              return (
                (u[e + 0] !== r ||
                  u[e + 1] !== o ||
                  u[e + 2] !== h ||
                  u[e + 3] !== d ||
                  u[e + 4] !== p ||
                  u[e + 5] !== w) &&
                ((u[e + 0] = r),
                (u[e + 1] = o),
                (u[e + 2] = h),
                (u[e + 3] = d),
                (u[e + 4] = p),
                (u[e + 5] = w),
                !0)
              );
            }
            {
              const n = e + 8,
                i = a[e + 6],
                s = n + r,
                c = i + r;
              let l = o,
                f = !1,
                h = !1;
              t
                ? l || ((f = t.has(s)), (h = t.has(c)), (l = !f && !h))
                : ((f = !0), (h = !0));
              const p = l || h;
              let w = !1;
              (l || f) && (w = d(n, r, l));
              let g = !1;
              p && (g = d(i, r, l));
              const y = w || g;
              if (y)
                for (let t = 0; t < 3; t++) {
                  const r = n + t,
                    s = i + t,
                    o = u[r],
                    a = u[r + 3],
                    c = u[s],
                    l = u[s + 3];
                  (u[e + t] = o < c ? o : c), (u[e + t + 3] = a > l ? a : l);
                }
              return y;
            }
          }
        }
        traverse(t, e = 0) {
          const n = this._roots[e],
            r = new Uint32Array(n),
            i = new Uint16Array(n);
          !(function e(s, o = 0) {
            const a = 2 * s,
              c = i[a + 15] === w;
            if (c) {
              const e = r[s + 6],
                u = i[a + 14];
              t(o, c, new Float32Array(n, 4 * s, 6), e, u);
            } else {
              const i = s + 8,
                a = r[s + 6],
                u = r[s + 7];
              t(o, c, new Float32Array(n, 4 * s, 6), u) ||
                (e(i, o + 1), e(a, o + 1));
            }
          })(0);
        }
        raycast(t, e = r.FrontSide) {
          const n = this._roots,
            i = this.geometry,
            s = [],
            o = e.isMaterial,
            a = Array.isArray(e),
            c = i.groups,
            u = o ? e.side : e;
          for (let r = 0, o = n.length; r < o; r++) {
            const o = a ? e[c[r].materialIndex].side : u,
              l = s.length;
            if ((N(n[r]), U(0, i, o, t, s), _(), a)) {
              const t = c[r].materialIndex;
              for (let e = l, n = s.length; e < n; e++)
                s[e].face.materialIndex = t;
            }
          }
          return s;
        }
        raycastFirst(t, e = r.FrontSide) {
          const n = this._roots,
            i = this.geometry,
            s = e.isMaterial,
            o = Array.isArray(e);
          let a = null;
          const c = i.groups,
            u = s ? e.side : e;
          for (let r = 0, s = n.length; r < s; r++) {
            const s = o ? e[c[r].materialIndex].side : u;
            N(n[r]);
            const l = H(0, i, s, t);
            _(),
              null != l &&
                (null == a || l.distance < a.distance) &&
                ((a = l), o && (l.face.materialIndex = c[r].materialIndex));
          }
          return a;
        }
        intersectsGeometry(t, e) {
          const n = this.geometry;
          let r = !1;
          for (const i of this._roots)
            if ((N(i), (r = z(0, n, t, e)), _(), r)) break;
          return r;
        }
        shapecast(t, e, n) {
          const r = this.geometry;
          if (t instanceof Function) {
            if (e) {
              const t = e;
              e = (e, n, r, i) => {
                const s = 3 * n;
                return t(e, s, s + 1, s + 2, r, i);
              };
            }
            (t = {
              boundsTraverseOrder: n,
              intersectsBounds: t,
              intersectsTriangle: e,
              intersectsRange: null,
            }),
              console.warn(
                "MeshBVH: Shapecast function signature has changed and now takes an object of callbacks as a second argument. See docs for new signature."
              );
          }
          const i = tt.getPrimitive();
          let {
            boundsTraverseOrder: s,
            intersectsBounds: o,
            intersectsRange: a,
            intersectsTriangle: c,
          } = t;
          if (a && c) {
            const t = a;
            a = (e, n, s, o, a) => !!t(e, n, s, o, a) || b(e, n, r, c, s, o, i);
          } else
            a ||
              (a = c ? (t, e, n, s) => b(t, e, r, c, n, s, i) : (t, e, n) => n);
          let u = !1,
            l = 0;
          for (const t of this._roots) {
            if ((N(t), (u = k(0, r, o, a, s, l)), _(), u)) break;
            l += t.byteLength;
          }
          return tt.releasePrimitive(i), u;
        }
        bvhcast(t, e, n) {
          let { intersectsRanges: r, intersectsTriangles: i } = n;
          const s = t.geometry,
            o = s.index,
            a = s.attributes.position;
          X.copy(e).invert();
          const c = tt.getPrimitive(),
            u = tt.getPrimitive();
          if (i) {
            function l(t, n, r, s, l, f, h, d) {
              for (let p = r, w = r + s; p < w; p++) {
                B(u, 3 * p, o, a),
                  u.a.applyMatrix4(e),
                  u.b.applyMatrix4(e),
                  u.c.applyMatrix4(e),
                  (u.needsUpdate = !0);
                for (let e = t, r = t + n; e < r; e++)
                  if (
                    (B(c, 3 * e, o, a),
                    (c.needsUpdate = !0),
                    i(c, u, e, p, l, f, h, d))
                  )
                    return !0;
              }
              return !1;
            }
            if (r) {
              const t = r;
              r = function (e, n, r, i, s, o, a, c) {
                return !!t(e, n, r, i, s, o, a, c) || l(e, n, r, i, s, o, a, c);
              };
            } else r = l;
          }
          this.getBoundingBox(R), R.applyMatrix4(e);
          const f = this.shapecast({
            intersectsBounds: (t) => R.intersectsBox(t),
            intersectsRange: (e, n, i, s, o, a) => (
              G.copy(a),
              G.applyMatrix4(X),
              t.shapecast({
                intersectsBounds: (t) => G.intersectsBox(t),
                intersectsRange: (t, i, a, c, u) => r(e, n, t, i, s, o, c, u),
              })
            ),
          });
          return tt.releasePrimitive(c), tt.releasePrimitive(u), f;
        }
        intersectsBox(t, e) {
          return (
            j.set(t.min, t.max, e),
            (j.needsUpdate = !0),
            this.shapecast({
              intersectsBounds: (t) => j.intersectsBox(t),
              intersectsTriangle: (t) => j.intersectsTriangle(t),
            })
          );
        }
        intersectsSphere(t) {
          return this.shapecast({
            intersectsBounds: (e) => t.intersectsBox(e),
            intersectsTriangle: (e) => e.intersectsSphere(t),
          });
        }
        closestPointToGeometry(t, e, n = {}, r = {}, i = 0, s = 1 / 0) {
          t.boundingBox || t.computeBoundingBox(),
            j.set(t.boundingBox.min, t.boundingBox.max, e),
            (j.needsUpdate = !0);
          const o = this.geometry,
            a = o.attributes.position,
            c = o.index,
            u = t.attributes.position,
            l = t.index,
            f = tt.getPrimitive(),
            h = tt.getPrimitive();
          let d = Z,
            p = W,
            w = null,
            g = null;
          r && ((w = J), (g = K));
          let y = 1 / 0,
            x = null,
            m = null;
          return (
            X.copy(e).invert(),
            $.matrix.copy(X),
            this.shapecast({
              boundsTraverseOrder: (t) => j.distanceToBox(t, Math.min(y, s)),
              intersectsBounds: (t, e, n) =>
                n < y &&
                n < s &&
                (e &&
                  ($.min.copy(t.min), $.max.copy(t.max), ($.needsUpdate = !0)),
                !0),
              intersectsRange: (n, r) => {
                if (t.boundsTree)
                  return t.boundsTree.shapecast({
                    boundsTraverseOrder: (t) =>
                      $.distanceToBox(t, Math.min(y, s)),
                    intersectsBounds: (t, e, n) => n < y && n < s,
                    intersectsRange: (t, s) => {
                      for (let o = 3 * t, b = 3 * (t + s); o < b; o += 3) {
                        B(h, o, l, u),
                          h.a.applyMatrix4(e),
                          h.b.applyMatrix4(e),
                          h.c.applyMatrix4(e),
                          (h.needsUpdate = !0);
                        for (let t = 3 * n, e = 3 * (n + r); t < e; t += 3) {
                          B(f, t, c, a), (f.needsUpdate = !0);
                          const e = f.distanceToTriangle(h, d, w);
                          if (
                            (e < y &&
                              (p.copy(d),
                              g && g.copy(w),
                              (y = e),
                              (x = t / 3),
                              (m = o / 3)),
                            e < i)
                          )
                            return !0;
                        }
                      }
                    },
                  });
                for (let t = 0, s = l ? l.count : u.count; t < s; t += 3) {
                  B(h, t, l, u),
                    h.a.applyMatrix4(e),
                    h.b.applyMatrix4(e),
                    h.c.applyMatrix4(e),
                    (h.needsUpdate = !0);
                  for (let e = 3 * n, s = 3 * (n + r); e < s; e += 3) {
                    B(f, e, c, a), (f.needsUpdate = !0);
                    const n = f.distanceToTriangle(h, d, w);
                    if (
                      (n < y &&
                        (p.copy(d),
                        g && g.copy(w),
                        (y = n),
                        (x = e / 3),
                        (m = t / 3)),
                      n < i)
                    )
                      return !0;
                  }
                }
              },
            }),
            tt.releasePrimitive(f),
            tt.releasePrimitive(h),
            y === 1 / 0
              ? null
              : (n.point ? n.point.copy(p) : (n.point = p.clone()),
                (n.distance = y),
                (n.faceIndex = x),
                r &&
                  (r.point ? r.point.copy(g) : (r.point = g.clone()),
                  r.point.applyMatrix4(X),
                  p.applyMatrix4(X),
                  (r.distance = p.sub(r.point).length()),
                  (r.faceIndex = m)),
                n)
          );
        }
        closestPointToPoint(t, e = {}, n = 0, r = 1 / 0) {
          const i = n * n,
            s = r * r;
          let o = 1 / 0,
            a = null;
          if (
            (this.shapecast({
              boundsTraverseOrder: (e) => (
                Y.copy(t).clamp(e.min, e.max), Y.distanceToSquared(t)
              ),
              intersectsBounds: (t, e, n) => n < o && n < s,
              intersectsTriangle: (e, n) => {
                e.closestPointToPoint(t, Y);
                const r = t.distanceToSquared(Y);
                return r < o && (Z.copy(Y), (o = r), (a = n)), r < i;
              },
            }),
            o === 1 / 0)
          )
            return null;
          const c = Math.sqrt(o);
          return (
            e.point ? e.point.copy(Z) : (e.point = Z.clone()),
            (e.distance = c),
            (e.faceIndex = a),
            e
          );
        }
        getBoundingBox(t) {
          t.makeEmpty();
          return (
            this._roots.forEach((e) => {
              i(0, new Float32Array(e), Q), t.union(Q);
            }),
            t
          );
        }
      }
      const et = MeshBVH.prototype.raycast;
      MeshBVH.prototype.raycast = function (...t) {
        if (t[0].isMesh) {
          console.warn(
            'MeshBVH: The function signature and results frame for "raycast" has changed. See docs for new signature.'
          );
          const [e, n, r, i] = t;
          return (
            et.call(this, r, e.material).forEach((t) => {
              (t = (0, m.O)(t, e, n)) && i.push(t);
            }),
            i
          );
        }
        return et.apply(this, t);
      };
      const nt = MeshBVH.prototype.raycastFirst;
      MeshBVH.prototype.raycastFirst = function (...t) {
        if (t[0].isMesh) {
          console.warn(
            'MeshBVH: The function signature and results frame for "raycastFirst" has changed. See docs for new signature.'
          );
          const [e, n, r] = t;
          return (0, m.O)(nt.call(this, r, e.material), e, n);
        }
        return nt.apply(this, t);
      };
      const rt = MeshBVH.prototype.closestPointToPoint;
      MeshBVH.prototype.closestPointToPoint = function (...t) {
        if (t[0].isMesh) {
          console.warn(
            'MeshBVH: The function signature and results frame for "closestPointToPoint" has changed. See docs for new signature.'
          ),
            t.unshift();
          const e = t[1],
            n = {};
          return (
            (t[1] = n), rt.apply(this, t), e && e.copy(n.point), n.distance
          );
        }
        return rt.apply(this, t);
      };
      const it = MeshBVH.prototype.closestPointToGeometry;
      MeshBVH.prototype.closestPointToGeometry = function (...t) {
        const e = t[2],
          n = t[3];
        if ((e && e.isVector3) || (n && n.isVector3)) {
          console.warn(
            'MeshBVH: The function signature and results frame for "closestPointToGeometry" has changed. See docs for new signature.'
          );
          const r = {},
            i = {},
            s = t[1];
          return (
            (t[2] = r),
            (t[3] = i),
            it.apply(this, t),
            e && e.copy(r.point),
            n && n.copy(i.point).applyMatrix4(s),
            r.distance
          );
        }
        return it.apply(this, t);
      };
      const st = MeshBVH.prototype.refit;
      (MeshBVH.prototype.refit = function (...t) {
        const e = t[0],
          n = t[1];
        if (n && (n instanceof Set || Array.isArray(n))) {
          console.warn(
            'MeshBVH: The function signature for "refit" has changed. See docs for new signature.'
          );
          const t = new Set();
          n.forEach((e) => t.add(e)),
            e && e.forEach((e) => t.add(e)),
            st.call(this, t);
        } else st.apply(this, t);
      }),
        [
          "intersectsGeometry",
          "shapecast",
          "intersectsBox",
          "intersectsSphere",
        ].forEach((t) => {
          const e = MeshBVH.prototype[t];
          MeshBVH.prototype[t] = function (...n) {
            return (
              (null === n[0] || n[0].isMesh) &&
                (n.shift(),
                console.warn(
                  `MeshBVH: The function signature for "${t}" has changed and no longer takes Mesh. See docs for new signature.`
                )),
              e.apply(this, n)
            );
          };
        });
    },
    864: (t, e, n) => {
      "use strict";
      n.d(e, { uL: () => u, Xy: () => l, sn: () => f });
      var r = n(2212),
        i = n(34003),
        s = n(96367);
      const o = new r.Ray(),
        a = new r.Matrix4(),
        c = r.Mesh.prototype.raycast;
      function u(t, e) {
        if (this.geometry.boundsTree) {
          if (void 0 === this.material) return;
          a.copy(this.matrixWorld).invert(), o.copy(t.ray).applyMatrix4(a);
          const n = this.geometry.boundsTree;
          if (!0 === t.firstHitOnly) {
            const r = (0, i.O)(n.raycastFirst(o, this.material), this, t);
            r && e.push(r);
          } else {
            const r = n.raycast(o, this.material);
            for (let n = 0, s = r.length; n < s; n++) {
              const s = (0, i.O)(r[n], this, t);
              s && e.push(s);
            }
          }
        } else c.call(this, t, e);
      }
      function l(t) {
        return (this.boundsTree = new s.r(this, t)), this.boundsTree;
      }
      function f() {
        this.boundsTree = null;
      }
    },
    34003: (t, e, n) => {
      "use strict";
      n.d(e, { O: () => w, rM: () => p, U$: () => d });
      var r = n(2212);
      const i = new r.Vector3(),
        s = new r.Vector3(),
        o = new r.Vector3(),
        a = new r.Vector2(),
        c = new r.Vector2(),
        u = new r.Vector2(),
        l = new r.Vector3();
      function f(t, e, n, f, h, d, p) {
        i.fromBufferAttribute(e, f),
          s.fromBufferAttribute(e, h),
          o.fromBufferAttribute(e, d);
        const w = (function (t, e, n, i, s, o) {
          let a;
          return (
            (a =
              o === r.BackSide
                ? t.intersectTriangle(i, n, e, !0, s)
                : t.intersectTriangle(e, n, i, o !== r.DoubleSide, s)),
            null === a
              ? null
              : { distance: t.origin.distanceTo(s), point: s.clone() }
          );
        })(t, i, s, o, l, p);
        if (w) {
          n &&
            (a.fromBufferAttribute(n, f),
            c.fromBufferAttribute(n, h),
            u.fromBufferAttribute(n, d),
            (w.uv = r.Triangle.getUV(l, i, s, o, a, c, u, new r.Vector2())));
          const t = {
            a: f,
            b: h,
            c: d,
            normal: new r.Vector3(),
            materialIndex: 0,
          };
          r.Triangle.getNormal(i, s, o, t.normal),
            (w.face = t),
            (w.faceIndex = f);
        }
        return w;
      }
      function h(t, e, n, r, i) {
        const s = 3 * r,
          o = t.index.getX(s),
          a = t.index.getX(s + 1),
          c = t.index.getX(s + 2),
          u = f(n, t.attributes.position, t.attributes.uv, o, a, c, e);
        return u ? ((u.faceIndex = r), i && i.push(u), u) : null;
      }
      function d(t, e, n, r, i, s) {
        for (let o = r, a = r + i; o < a; o++) h(t, e, n, o, s);
      }
      function p(t, e, n, r, i) {
        let s = 1 / 0,
          o = null;
        for (let a = r, c = r + i; a < c; a++) {
          const r = h(t, e, n, a);
          r && r.distance < s && ((o = r), (s = r.distance));
        }
        return o;
      }
      function w(t, e, n) {
        return null === t
          ? null
          : (t.point.applyMatrix4(e.matrixWorld),
            (t.distance = t.point.distanceTo(n.ray.origin)),
            (t.object = e),
            t.distance < n.near || t.distance > n.far ? null : t);
      }
    },
  },
]);
